package com.hospital.schedule.module.controller;


import com.hospital.common.base.Result;
import com.hospital.common.dto.schedule.module.*;
import com.hospital.schedule.module.service.ITDoctorScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 排班表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-09-11
 */
@RestController
//@RequestMapping("/t-docter-schedule")
public class TDoctorScheduleController {
    @Autowired
    private ITDoctorScheduleService tDoctorScheduleService;
    /**
     * 添加排班信息,以字段显示线上线下
     * @param addDoctorScheduleDtoList
     * @return
     */
    @PostMapping("/addDoctorSchedule")
    public Result addDoctorSchedule(@RequestBody ArrayAddDoctorScheduleDto addDoctorScheduleDtoList){
        boolean save = tDoctorScheduleService.addDoctorSchedule(addDoctorScheduleDtoList.getAddDoctorScheduleDtoList());
        if (save){
            return Result.success("添加成功");
        }
        return Result.fail("添加失败");
    }
    /**
     * 查询医生今天是否有排班信息，有则返回1，无则返回0
     * 线下0线上1
     * x
     */
    @PostMapping("/findDoctorScheduleByTime")
    public Result findDoctorScheduleByTime(@RequestBody FindDoctorScheduleByTimeDto findDoctorScheduleByTimeDto){
        return Result.success(tDoctorScheduleService.findDoctorScheduleByTime(findDoctorScheduleByTimeDto));
    }

    /**
     * 医生查询排班信息，今天之后，时间我处理了，传入的我自动变成00:00:00
     * @param findDoctorScheduleByDoctorDto
     * @return
     */
    @PostMapping("/findDoctorScheduleByDoctor")
    public Result findDoctorScheduleByDoctor(@RequestBody FindDoctorScheduleByDoctorDto findDoctorScheduleByDoctorDto ){
        return Result.success(tDoctorScheduleService.findDoctorScheduleByDoctor(findDoctorScheduleByDoctorDto));
    }

    /**
     * 管理端查询排班信息
     * @param findDoctorScheduleByAdminDto 查询参数
     * @return 排班信息
     */
    @PostMapping("/findDoctorScheduleByAdmin")
    public Result findDoctorScheduleByAdmin(@RequestBody FindDoctorScheduleByAdminDto findDoctorScheduleByAdminDto ){
        return Result.success(tDoctorScheduleService.findDoctorScheduleByAdmin(findDoctorScheduleByAdminDto));
    }
    /**
     * 排班时选择医生后查询是否有排班
     * @param findDoctorScheduleOfScheduleDto 查询参数
     * @return 1、有排班 0、无排班
     */
    @PostMapping("/fineDoctorByDoctorSchedule")
    public Result fineDoctorBySchedule(@RequestBody FindDoctorScheduleOfScheduleDto findDoctorScheduleOfScheduleDto){
        return Result.success(tDoctorScheduleService.fineDoctorBySchedule(findDoctorScheduleOfScheduleDto));
    }

}
